<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>商品类表</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery-validate/1.11.1/jquery.validate.min.js"></script>
    <script type="text/javascript"
            src="https://cdn.bootcss.com/jquery-validate/1.11.1/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
    <script type="text/javascript" src="./js/common-min.js"></script>
    <style>
        .panel-p {
            font-weight: 600;
            text-align: center;
            background-color: #fff;
            width: 60%;
            margin: auto;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin-top: 13%;
        }
    </style>
</head>
<body>
<div class="panel panel-primary panel-p">
    <div class="panel-heading">秒杀列表</div>
    <table class="table" id="goodsList">
        <tr>
            <td>商品名称</td>
            <td>商品图片</td>
            <td>商品原价</td>
            <td>秒杀价</td>
            <td>库存数量</td>
            <td>详情</td>
        </tr>
    </table>
</div>
</body>
<script>
    $(function () {
        do_list();
    });

    function do_list() {
        $.ajax({
            url: "./goods/to_list",
            type: "GET",
            success: function (data) {
                layer.closeAll();
                if (data.code == 0) {
                    $.each(data.data, function (idx, item) {
                        var html = "<tr><td>" + item.goodsName + "</td><td><img src=" + item.goodsImg + " width='100' height='100'/></td>" +
                            "<td>" + item.goodsPrice + "</td> <td>" + item.seckillPrice + "</td> <td >" + item.stockCount + "</td>" +
                            "<td><a href=./goods_detail.html?goodsId=" + item.id + ">详情</a></td> </tr>"
                        $("#goodsList").append(html);
                    });
                } else {
                    layer.msg(data.msg);
                }
                console.log(data);
            },
            error: function () {
                layer.closeAll();
            }
        });
    }
</script>
</html>